package com.binest.myNolikes.service.impl;

import java.util.List;

import com.binest.common.core.domain.entity.SysUser;
import com.binest.common.core.domain.model.LoginUser;
import com.binest.common.utils.DateUtils;
import com.binest.common.utils.uuid.IdUtils;
import com.binest.figureInclusionMain.service.IFigureInclusionMainService;
import com.binest.hackathonInclusionMain.service.IHackathonInclusionMainService;
import com.binest.investorInclusionMain.service.IInvestorInclusionMainService;
import com.binest.kolInclusionMain.service.IKolInclusionMainService;
import com.binest.meetingInclusionMain.service.IMeetingInclusionMainService;
import com.binest.projectInclusionMain.service.IProjectInclusionMainService;
import com.binest.toolInclusionMain.service.IToolInclusionMainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.binest.myNolikes.mapper.MyNolikesMapper;
import com.binest.myNolikes.domain.MyNolikes;
import com.binest.myNolikes.service.IMyNolikesService;

import static com.binest.common.utils.SecurityUtils.getLoginUser;

/**
 * 我的不喜欢Service业务层处理
 * 
 * @author wwd
 * @date 2024-01-31
 */
@Service
public class MyNolikesServiceImpl implements IMyNolikesService 
{
    @Autowired
    private MyNolikesMapper myNolikesMapper;

    @Autowired
    private IProjectInclusionMainService projectInclusionMainService;

    @Autowired
    private IFigureInclusionMainService figureInclusionMainService;

    @Autowired
    private IHackathonInclusionMainService hackathonInclusionMainService;

    @Autowired
    private IInvestorInclusionMainService investorInclusionMainService;

    @Autowired
    private IMeetingInclusionMainService meetingInclusionMainService;


    @Autowired
    private IKolInclusionMainService kolInclusionMainService;

    @Autowired
    private IToolInclusionMainService toolInclusionMainService;

    /**
     * 查询我的不喜欢
     * 
     * @param id 我的不喜欢主键
     * @return 我的不喜欢
     */
    @Override
    public MyNolikes selectMyNolikesById(String id)
    {
        return myNolikesMapper.selectMyNolikesById(id);
    }

    /**
     * 查询我的不喜欢列表
     * 
     * @param myNolikes 我的不喜欢
     * @return 我的不喜欢
     */
    @Override
    public List<MyNolikes> selectMyNolikesList(MyNolikes myNolikes)
    {
        return myNolikesMapper.selectMyNolikesList(myNolikes);
    }

    /**
     * 新增我的不喜欢
     * 
     * @param myNolikes 我的不喜欢
     * @return 结果
     */
    @Override
    public int insertMyNolikes(MyNolikes myNolikes)
    {
     
        //获取当前登录用户
        LoginUser loginUser = getLoginUser();
        SysUser currentUser = loginUser.getUser();

        myNolikes.setCreateTime(DateUtils.getNowDate());
        myNolikes.setId(IdUtils.simpleUUID());
        myNolikes.setCreateBy(currentUser.getUserId().toString());
        //判断收录类型 点赞
        if(myNolikes.getInclusionType().equals("0")){
            //项目
            if(myNolikes.getStatus().equals("0")){
                projectInclusionMainService.addNoLikeCount(myNolikes.getInclusionMainId());
            }else {
                projectInclusionMainService.reduceNoLikeCount(myNolikes.getInclusionMainId());
            }

        } else if(myNolikes.getInclusionType().equals("1")){
            //投资机构
            if(myNolikes.getStatus().equals("0")){
                investorInclusionMainService.addNoLikeCount(myNolikes.getInclusionMainId());
            }else {
                investorInclusionMainService.reduceNoLikeCount(myNolikes.getInclusionMainId());
            }


        } else if(myNolikes.getInclusionType().equals("2")){
            //人物
            if(myNolikes.getStatus().equals("0")){
                figureInclusionMainService.addNoLikeCount(myNolikes.getInclusionMainId());
            }else {
                figureInclusionMainService.reduceNoLikeCount(myNolikes.getInclusionMainId());
            }

        } else if(myNolikes.getInclusionType().equals("3")){
            //会议
            if(myNolikes.getStatus().equals("0")){
                meetingInclusionMainService.addNoLikeCount(myNolikes.getInclusionMainId());
            }else {
                meetingInclusionMainService.reduceNoLikeCount(myNolikes.getInclusionMainId());
            }

        } else if(myNolikes.getInclusionType().equals("4")){
            //kol
            if(myNolikes.getStatus().equals("0")){
                kolInclusionMainService.addNoLikeCount(myNolikes.getInclusionMainId());
            }else {
                kolInclusionMainService.reduceNoLikeCount(myNolikes.getInclusionMainId());
            }

        } else if(myNolikes.getInclusionType().equals("6")){
            //工具
            if(myNolikes.getStatus().equals("0")){
                toolInclusionMainService.addNoLikeCount(myNolikes.getInclusionMainId());
            }else {
                toolInclusionMainService.reduceNoLikeCount(myNolikes.getInclusionMainId());
            }
        } else if(myNolikes.getInclusionType().equals("7")){
            //马拉松
            if(myNolikes.getStatus().equals("0")){
                hackathonInclusionMainService.addNoLikeCount(myNolikes.getInclusionMainId());
            }else {
                hackathonInclusionMainService.reduceNoLikeCount(myNolikes.getInclusionMainId());
            }

        }
        
        
        
        
        
        
        
        
        return myNolikesMapper.insertMyNolikes(myNolikes);
    }

    /**
     * 修改我的不喜欢
     * 
     * @param myNolikes 我的不喜欢
     * @return 结果
     */
    @Override
    public int updateMyNolikes(MyNolikes myNolikes)
    {
        myNolikes.setUpdateTime(DateUtils.getNowDate());
        return myNolikesMapper.updateMyNolikes(myNolikes);
    }

    /**
     * 批量删除我的不喜欢
     * 
     * @param ids 需要删除的我的不喜欢主键
     * @return 结果
     */
    @Override
    public int deleteMyNolikesByIds(String[] ids)
    {
        return myNolikesMapper.deleteMyNolikesByIds(ids);
    }

    /**
     * 删除我的不喜欢信息
     * 
     * @param id 我的不喜欢主键
     * @return 结果
     */
    @Override
    public int deleteMyNolikesById(String id)
    {
        return myNolikesMapper.deleteMyNolikesById(id);
    }
}
